﻿Select top 10 * from [Order]

ALTER TABLE [Order] ADD OrderGroupGuid UNIQUEIDENTIFIER NULL
GO
CREATE NONCLUSTERED INDEX [IX_Order_OrderGroupGuid]
    ON [dbo].[Order]([OrderGroupGuid] ASC);

ALTER TABLE [dbo].[Order] DROP CONSTRAINT [Order_FirstPreferredTimeWindow];
ALTER TABLE [Order] DROP COLUMN FirstPreferredTimeWindowId;
ALTER TABLE [dbo].[Order] DROP CONSTRAINT [Order_SecondPreferredTimeWindow];
ALTER TABLE [Order] DROP COLUMN SecondPreferredTimeWindowId;

Select * from SurchargeType
INSERT INTO SurchargeType VALUES('GST', 'GST', 0, 0)
INSERT INTO SurchargeType VALUES('PST', 'PST', 0, 1)

UPDATE [dbo].[Region] SET [Name] = N'Vancouver' WHERE id = 1

SET IDENTITY_INSERT [dbo].[Region] ON
INSERT INTO [dbo].[Region] ([Id], [Name], [DisplayOrder]) VALUES (2, N'Calgary', 1)
INSERT INTO [dbo].[Region] ([Id], [Name], [DisplayOrder]) VALUES (3, N'Edmonton', 2)
SET IDENTITY_INSERT [dbo].[Region] OFF

Select * from Region

UPDATE Customer SET Customer.Region_Id = d.RegionId FROM Customer c INNER JOIN GenericAttribute g ON c.Id = g.EntityId INNER JOIN LogisticsZone z ON z.ZipPostalCode LIKE '%' + SUBSTRING(g.Value, 1, 3) + '%' INNER JOIN LogisticsDistrict d ON d.Id = z.DistrictId WHERE Region_Id IS NOT NULL AND g.[Key] = 'ZipPostalCode' AND Deleted = 0 AND d.RegionId != c.Region_Id

SELECT c.Region_Id FROM Customer c INNER JOIN GenericAttribute g ON c.Id = g.EntityId INNER JOIN LogisticsZone z ON z.ZipPostalCode LIKE '%' + SUBSTRING(g.Value, 1, 3) + '%' INNER JOIN LogisticsDistrict d ON d.Id = z.DistrictId WHERE Region_Id IS NOT NULL AND g.[Key] = 'ZipPostalCode' AND Deleted = 0 AND d.RegionId != c.Region_Id

GRANT REFERENCES ON SCHEMA::[dbo] TO siteuser
--TAX!

--Set Returning address _orderSettings.ReturnAddressId

--SELECT * FROM Topic

--INSERT INTO Topic VALUES ('', )

--Remove the store close

--Shipping plugin
